<template>
  <div class="supplier-wrapper">
    <div class="supplier-name">
      {{ data.name }}
    </div>
    <div class="supplier-rate">
      <div class="supplier-rate-item" v-for="(item,index) in data.supplierRateList" :key="index">
        <svg-icon size="12" :icon-class="item.icon"></svg-icon>
        <span>{{ item.name }}</span>
        <div class="rate-item-star-wrapper">
          <rate-star :rate="item.rate" size="small"></rate-star>
        </div>
      </div>
    </div>
    <a-tabs style="margin-top: 6px;" size="small"  :activeKey="activeContactKey" @change="tabChange">
      <a-tab-pane v-for="(contact,contactIndex) in data.contactList" :key="contact.id" :tab="'联系人'+(contactIndex+1)">
        <div class="contact-item">
          <span>联系人：</span>
          <div>{{ contact.contactName || '-' }}</div>
        </div>
        <div class="contact-item">
          <span>电话：</span>
          <div>{{ contact.contactPhone || '-' }}</div>
        </div>
        <div class="contact-item">
          <span>邮件：</span>
          <div>{{ contact.contactEmail || '-' }}</div>
        </div>
        <div class="contact-item">
          <span>办公：</span>
          <div>{{ contact.contactTel || '-' }}</div>
        </div>
        <div class="contact-item">
          <span>备注：</span>
          <div>{{ contact.remark || '-' }}</div>
        </div>
        <!-- <div class="contact-item">
          <span>职务：</span>
          <div>{{ contact.contactTitle || '-' }}</div>
        </div>
        <div class="contact-item">
          <span>地址：</span>
          <div>{{ contact.registerAddr || '-' }}</div>
        </div> -->
      </a-tab-pane>
    </a-tabs>
    <div class="supplier-bottom" v-if="data.isTrim">
      <a-button class="supplier-btn" type="primary" @click="$emit('goShop')">进入店铺</a-button>
      <svg-icon size="24" icon-class="consult" style="cursor: pointer;"></svg-icon>
    </div>
  </div>
</template>

<script>
import RateStar from '@/components/RateStar'

export default {
  name: 'Supplier',
  components: {RateStar},
  props: {
    data: {
      name: '',
      supplierRateList: [],
      contactList: []
    },
    activeContactKey: ''
  },
  data () {
    return {}
  },
  methods: {
    tabChange (e) {
      this.$emit('change', e)
    }
  }
}
</script>

<style scoped lang="scss">
$mainColor: #0078FE;
.supplier-wrapper {
  margin-top: 40px;
  background: #FFFFFF;
  border-radius: 10px;
  border: 1px solid #E2E2E2;
  padding: 20px;

  .supplier-name {
    font-size: 16px;
    font-family: PingFangSC-Medium, PingFang SC, sans-serif;
    font-weight: 500;
    color: #323232;
    line-height: 20px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #E2E2E2;
    margin-bottom: 10px;
  }

  .supplier-rate {
    display: flex;
    flex-wrap: wrap;

    .supplier-rate-item {
      display: flex;
      width: calc((100% - 20px) / 2);
      align-items: center;
      font-size: 12px;
      font-family: PingFangSC-Regular, PingFang SC, sans-serif;
      font-weight: 400;
      color: #646464;
      line-height: 12px;
      margin-bottom: 10px;

      &:nth-child(2n) {
        margin-left: 20px;
      }

      span {
        margin-left: 6px;
        margin-right: 8px;
      }

      .rate-item-star-wrapper {
        flex: 1;
        display: flex;
      }
    }
  }

  .contact-item {
    display: flex;
    align-items: flex-start;
    font-size: 12px;
    font-family: PingFangSC-Regular, PingFang SC, sans-serif;
    font-weight: 400;
    color: #646464;
    line-height: 16px;
    margin-bottom: 6px;

    span {
      width: 60px;
    }

    div {
      flex: 1;
      color: #323232;
    }
  }

  .supplier-bottom {
    margin-top: 14px;
    display: flex;
    align-items: center;

    .supplier-btn {
      background: $mainColor;
      flex: 1;
      margin-right: 28px;
    }
  }
}
</style>
